package com.javacoo.junit.generator.internal;

import com.javacoo.junit.generator.internal.data.PrimitiveType;

/**
 * <li></li>
 *
 * @author: duanyong@jccfc.com
 * @since: 2021/1/7 12:48
 */
public class AssertClause {
    private static final String ASSERT = "assertEquals(\"%s方法\", %s, %s);";

    public static String get(Class clazz,String methodName, String variableName) {

        String expectedValue = PrimitiveType.get(clazz);
        if("null".equals(expectedValue)){
            return "assertNotNull("+variableName+");";
        }
        if("boolean".equals(clazz.getSimpleName())||"Boolean".equals(clazz.getSimpleName())){
            return "assertFalse("+variableName+");";
        }else if(clazz.isArray()){
            return "assertArrayEquals("+expectedValue+", "+variableName+");";
        }
        return String.format(ASSERT, methodName,expectedValue, variableName);
    }
}
